package com.lanou.dao.impl;

import com.lanou.bean.Sec;
import com.lanou.dao.SecDao;
import com.lanou.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class SecDaoImpl implements SecDao {
    private Connection connection;
    private PreparedStatement pstm;
    private ResultSet rs;

    @Override
    public void insertInfo(Sec sec) throws Exception {

        String sql = "INSERT INTO sec2 (imgsrc, title, price) VALUES (?,?,?)";

        System.out.println(sec);

        connection = JDBCUtils.getConnection();
        pstm = connection.prepareStatement(sql);

        pstm.setString(1, sec.getImgsrc());
        pstm.setString(2, sec.getTitle());
        pstm.setString(3, sec.getPrice());
        pstm.executeUpdate();
        JDBCUtils.close(pstm, connection);
    }

}
